package testes.vSys.dao;

import java.util.Collection;
import java.util.LinkedHashMap;

import testes.vSys.bean.Brand;
import testes.vSys.bean.Color;
import testes.vSys.bean.Fuel;
import testes.vSys.bean.Location;
import testes.vSys.bean.Model;
import testes.vSys.bean.Vehicle;

public class _stub_VehicleDao implements IVehicleDao{

	private LinkedHashMap<Integer, Vehicle> vehicles;
	private int currentId = 4;
	
	private LinkedHashMap<Integer, Fuel> fuels;
	private LinkedHashMap<Integer, Color> colors;
	
	public _stub_VehicleDao() {
		vehicles = new LinkedHashMap<Integer, Vehicle>();
		fuels = new LinkedHashMap<Integer, Fuel>();
		colors = new LinkedHashMap<Integer, Color>();
		
		colors.put(1, new Color(1,"Branco"));
		colors.put(2, new Color(2,"Preto"));
		colors.put(3, new Color(3,"Prata"));
		colors.put(4, new Color(4,"Verde"));
		
		fuels.put(1, new Fuel(1, "Gasolina"));
		fuels.put(2, new Fuel(2, "Alcool"));
		fuels.put(3, new Fuel(3, "Flex"));
		
		Vehicle vehicle = null;
		
		vehicle = new Vehicle();
		vehicle.setId(1);
		vehicle.setPlate("HDF1234");
		vehicle.setYear(1999);
		vehicle.setLocation(new Location("SP","Tatui"));
		vehicle.setFuel(fuels.get(1));
		vehicle.setColor(colors.get(1));
		vehicle.setModel(new Model(1,new Brand(1,"Ford"),null,"Focus"));
		vehicles.put(1,vehicle);

		vehicle = new Vehicle();
		vehicle.setId(2);
		vehicle.setPlate("TYS8765");
		vehicle.setYear(2005);
		vehicle.setLocation(new Location("SP","Campinas"));
		vehicle.setFuel(fuels.get(2));
		vehicle.setColor(colors.get(2));
		vehicle.setModel(new Model(1,new Brand(2,"Fiat"),null,"Strada"));
		vehicles.put(2,vehicle);
		
		vehicle = new Vehicle();
		vehicle.setId(3);
		vehicle.setPlate("VBC6752");
		vehicle.setYear(2003);
		vehicle.setLocation(new Location("SP","S�o Paulo"));
		vehicle.setFuel(fuels.get(3));
		vehicle.setColor(colors.get(3));
		vehicle.setModel(new Model(1,new Brand(1,"Ford"),null,"Fiesta"));
		vehicles.put(3,vehicle);
	}
	
	public Collection<Color> getAvaiableColors() {
		return colors.values();
	}

	public Collection<Fuel> getAvaiableFuels() {
		return fuels.values();
	}


	public Vehicle createVehicle(Vehicle vehicle) {
		currentId++;
		vehicle.setId(currentId);
		return vehicles.put(currentId, vehicle);
	}

	public Vehicle getVehicleById(int id) {
		return vehicles.get(id);
	}

	public Vehicle getVehicleByPlate(String plate) {
		
		Vehicle vehicle = new Vehicle();
		
		vehicle.setId(3);
		vehicle.setPlate("VBC6752");
		vehicle.setYear(2003);
		vehicle.setLocation(new Location("SP","S�o Paulo"));
		vehicle.setFuel(fuels.get(3));
		vehicle.setColor(colors.get(3));
		vehicle.setModel(new Model(1,new Brand(1,"Ford"),null,"Fiesta"));
		// TODO Auto-generated method stub
		return vehicle;
	}

	public Collection<Vehicle> getVehicles() {
		return vehicles.values();
	}

	public Collection<Vehicle> getVehicles(String optionOrderBy) {
		if (optionOrderBy.equals("brand") == true)
		{
			vehicles.remove(1);
		}
		return vehicles.values();
	}
	
	public boolean removeVehicle(int vehicleId) {
		vehicles.remove(vehicleId);
		return true;
	}

	public boolean updateVehicle(Vehicle vehicle) {
		vehicles.put(vehicle.getId(), vehicle);
		return true;
	}

	public Color getColorById(int colorId) {
		return colors.get(colorId);
	}

	public Fuel getFuelById(int fuelId) {
		return fuels.get(fuelId);
	}

	public Collection<Vehicle> getVehicles(Vehicle vehicle) {
		// TODO Auto-generated method stub
		return null;
	}

	public Collection<Vehicle> getVehicle(String vehicleId, String plate, String initYear, String endYear, String initValue, String endValue, String color, String model, String brand, String fuel, String city, String state) {
		// TODO Auto-generated method stub
		return null;
	}

}
